const { exec } = require('../db/mysql');
const { genPassword } = require('../utils/cryp');

const login = (username, password) => {
    // password = genPassword(password);
    let sql = `select username, realname from users where username='${username}' 
              and password='${password}'`;
    // select 返回的是数组对象          
    return exec(sql).then(rows => {
        return rows[0] || {};
    })
}

module.exports = {
    login
}